package com.czk.springboot.reactive.reactor.limit;

import reactor.core.publisher.Flux;

public class LimitDemo {
    public static void main(String[] args) {
        /**
         *  INFO] (main) | request(30)
         * [ INFO] (main) | onNext(1)
         * [ INFO] (main) | onNext(2)
         * [ INFO] (main) | onNext(3)
         * [ INFO] (main) | onNext(4)
         * [ INFO] (main) | onNext(5)
         * [ INFO] (main) | onNext(6)
         * [ INFO] (main) | onNext(7)
         * [ INFO] (main) | onNext(8)
         * [ INFO] (main) | onNext(9)
         * [ INFO] (main) | onNext(10)
         * [ INFO] (main) | onNext(11)
         * [ INFO] (main) | onNext(12)
         * [ INFO] (main) | onNext(13)
         * [ INFO] (main) | onNext(14)
         * [ INFO] (main) | onNext(15)
         * [ INFO] (main) | onNext(16)
         * [ INFO] (main) | onNext(17)
         * [ INFO] (main) | onNext(18)
         * [ INFO] (main) | onNext(19)
         * [ INFO] (main) | onNext(20)
         * [ INFO] (main) | onNext(21)
         * [ INFO] (main) | onNext(22)
         * [ INFO] (main) | onNext(23)
         * [ INFO] (main) | request(23)
         *
         * 23 后再次摘取
         * 75%预取策略，如果75%元素已经被处理了，则再次抓取新的75%个元素
         */
        Flux.range(1, 100)
                .log()
                .limitRate(30)
                .subscribe();
    }
}
